<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <title>上传补丁</title>

    <meta name="description" content="overview &amp; stats"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

    <!-- bootstrap & fontawesome -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="assets/css/font-awesome.min.css"/>

    <!-- page specific plugin styles -->

    <!-- text fonts -->
    <link rel="stylesheet" href="assets/css/ace-fonts.css"/>

    <!-- ace styles -->
    <link rel="stylesheet" href="assets/css/ace.min.css" id="main-ace-style"/>

    <link rel="stylesheet" href="assets/css/ace-skins.min.css"/>
    <link rel="stylesheet" href="assets/css/ace-rtl.min.css"/>


    <!-- ace settings handler -->
    <script src="assets/js/ace-extra.min.js"></script>


    <script src="assets/js/bootstrap.min.js"></script>

    <!-- page specific plugin scripts -->
    <script src="assets/js/fuelux/fuelux.wizard.min.js"></script>
    <script src="assets/js/jquery.validate.min.js"></script>
    <script src="assets/js/additional-methods.min.js"></script>
    <script src="assets/js/bootbox.min.js"></script>
    <script src="assets/js/jquery.maskedinput.min.js"></script>
    <script src="assets/js/select2.min.js"></script>

    <!-- ace scripts -->
    <script src="assets/js/ace-elements.min.js"></script>
    <script src="assets/js/ace.min.js"></script>

    <script src="assets/js/ace-extra.min.js"></script>



</head>

<body>
<script src="assets/js/jquery-1.10.2.min.js"></script>
<script src="assets/ajaxfileupload.js"></script>

<script type="text/javascript">

    function ajaxFileUpload() {
        //执行上传文件操作的函数，使用encodeURI方法，防止传输中文字符的时候出现乱码
        var uploadUrl = '/uploadPatchFile';
        $.ajaxFileUpload({
            //处理文件上传操作的服务器端地址(可以传参数,已亲测可用)
            url: uploadUrl,
            secureuri: false,                       //是否启用安全提交,默认为false
            fileElementId: 'uploadFileInput',           //文件选择框的id属性
            dataType: 'text',                       //服务器返回的格式,可以是json或xml等
            success: function (data, status) {        //服务器响应成功时的处理函数
                data = data.replace("<PRE>", '');  //ajaxFileUpload会对服务器响应回来的text内容加上<pre>text</pre>前后缀
                data = data.replace("</PRE>", '');
                data = data.replace("<pre>", '');
                data = data.replace("</pre>", ''); //本例中设定上传文件完毕后,服务端会返回给前台[0`filepath]

                //将String字符串转换成json
                var dataset = $.parseJSON(data);
                if (dataset.status == "OK") {
                    alert(dataset.realPath);
                    $("input[name='realPath']").val(dataset.realPath);
                    alert("上传成功");
                } else if (dataset.status == "Empty") {
                    alert("没有选择文件！");
                } else {
                    alert('上传失败，请重试！！');
                }
            },
            error: function (data, status, e) { //服务器响应失败时的处理函数
                console.log(e);
                console.log(data);
                alert('上传失败，请重试！！');
            }
        });
    }
</script>

<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="main-content">


        <div class="page-content">


            <div class="page-content-area">


                <div class="row">
                    <div class="col-xs-12">






                                    <div id="uploadDiv">
                                        <div class="form-group has-warning">
                                            <label class="col-xs-12 col-sm-3 control-label no-padding-right">上传文件</label>

                                            <div class="col-xs-12 col-sm-5">
																<span class="block input-icon input-icon-right">

																	 <input type="file" id="uploadFileInput"
                                                                            name="uploadFile"/>

                                                                    <input type="button" value="上传"
                                                                           onclick="ajaxFileUpload()"/>
                                                                    <input type="hidden" id="realPath" name="realPath"/>
																</span>
                                            </div>
                                        </div>


                            </div>


                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content-area -->
        </div>
        <!-- /.page-content -->
    </div>
    <!-- /.main-content -->


</div>


<div id="dlg">
</div>


</body>


